package com.example.hcbmsm.service.impl;

import com.example.hcbmsm.domain.Inbound;
import com.example.hcbmsm.domain.InboundExample;
import com.example.hcbmsm.mapper.InboundMapper;
import com.example.hcbmsm.service.InboundService;
import com.example.hcbmsm.util.HCBMSMResult;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/11/5 15:05
 */
@Service
public class InboundServiceImpl implements InboundService {
    @Autowired
    private InboundMapper inboundMapper;
    @Override
    public void add(Inbound inbound) {
        inboundMapper.insertSelective(inbound);
    }

    @Override
    public Map list(int page, int limit) {
        Integer total = inboundMapper.selectInboundList().size();
        PageHelper.startPage(page, limit);
        List<Inbound> list = inboundMapper.selectInboundList();
        Map map = new HashMap<>();
        map.put("total", total);
        map.put("data", list);
        return HCBMSMResult.SUCCESS(map);
    }
}
